package com.yuncheng.spcyApi.flowController;

import com.yuncheng.vo.CurrentUserVo;
import com.yuncheng.vo.HttpResult;
import org.apache.commons.collections.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuncheng.spcyApi.alog.annotation.Log;
import com.yuncheng.spcyApi.busService.BusService;
import com.yuncheng.spcyApi.constant.common.LogConstant;
import com.yuncheng.spcyApi.constant.common.SpcyConstant;
import com.yuncheng.spcyApi.constant.flow.YlqxFlowConstant;
import com.yuncheng.spcyApi.constant.flow.YpscFlowConstant;
import com.yuncheng.spcyApi.entity.SpcySqsxBasic;
import com.yuncheng.spcyApi.entity.SpcySqsxJob;
import com.yuncheng.spcyApi.flowService.YlqxFlowService;
import com.yuncheng.spcyApi.flowService.YpscFlowService;
import com.yuncheng.spcyApi.service.ISpcyLogService;
import com.yuncheng.spcyApi.service.ISpcySqsxBaiscService;
import com.yuncheng.spcyApi.service.ISpcySqsxJobService;
import com.yuncheng.spcyApi.utils.GetCurrentUserUtils;
import com.yuncheng.spcyApi.vo.common.Result;
import com.yuncheng.spcyApi.vo.flow.AgentVo;
import com.yuncheng.spcyApi.vo.spcy.SpcyReturnVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

//@Api(tags = "审评查验-医疗器械流程接口")
@RestController
@RequestMapping("/api/spzx-spcy/flow-ylqx")
public class SpcyFlowYlqxController {
    private static final Logger log = LoggerFactory.getLogger(SpcyFlowYlqxController.class);

    @Resource
    @Lazy
    private ISpcySqsxBaiscService spcySqsxBaiscService;

    @Resource
    @Lazy
    private ISpcySqsxJobService spcySqsxJobService;

    @Resource
    @Lazy
    private BusService busService;

    @Resource
    @Lazy
    private ISpcyLogService spcyLogService;

    /*

    @Resource
    @Lazy
    private YpzcFlowService ypzcFlowService;

    @Resource
    @Lazy
    private YpltFlowService ypltFlowService;

    @Resource
    @Lazy
    private HzpFlowService hzpFlowService;*/

    @Resource
    @Lazy
    private YpscFlowService ypscFlowService;

    @Resource
    @Lazy
    private YlqxFlowService ylqxFlowService;

    /**
     * 现场检查+技术审评模式-获取已办列表-通过当前流程id
     * @param jobid
     * @return
     */
    @Log(title = "现场检查+技术审评模式-获取已办列表-通过当前流程id")
    @ApiOperation(value = "现场检查+技术审评模式-获取已办列表-通过当前流程id")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "jobid",value = "流程任务id"),
            @ApiImplicitParam(name = "isZdhj",value = "是否指定环节，默认：false，不指定")
    })
    @GetMapping(value = "queryScSpYbJob")
    public HttpResult<?> queryScSpYbJob(@RequestParam(value = "jobid",defaultValue = "")String jobid,
                                        @RequestParam(value = "isZdhj",defaultValue = "false")boolean isZdhj){

        List<Map<String, String>> currentJobPrevious = ypscFlowService.getCurrentJobPrevious(jobid, isZdhj);
        return HttpResult.ok(currentJobPrevious);
    }

    /**
     * 现场检查+技术审评模式-退回上一个环节
     * @param spcyReturnVo jobid (流程任务id) / opinion (退回意见) / shjid （退回环节id）
     * @return
     */
    @Log(title = "现场检查+技术审评模式-退回环节")
    @ApiOperation(value = "现场检查+技术审评模式-退回环节")
    @PostMapping(value = "returnUpperScSpFlowJob")
    public HttpResult<?> returnUpperScSpFlowJobOld(@RequestBody SpcyReturnVo spcyReturnVo){
        ypscFlowService.returnZdJob(spcyReturnVo);
        return HttpResult.ok("退回成功");
    }

    @Log(title = "获取医疗器械-任务分配人员")
    @ApiOperation(value = "获取医疗器械-任务分配人员")
    @GetMapping(value = "getYlqxRwfpUserDbList")
    public HttpResult<?> getYlqxRwfpUserDbList(){
        Map nodeDbr = ylqxFlowService.getNodeDbr(null, YlqxFlowConstant.HJMC_FAZZ, null);
        List<AgentVo> dbrListByMap = busService.getDbrListByMap(nodeDbr);

        Map resultMap = new HashMap();
        resultMap.put("nextNodeDbrList", dbrListByMap);
        return HttpResult.ok(resultMap);
    }

    @Log(title = "批量提交任务受理到任务分配环节")
    @ApiOperation(value = "批量提交任务受理到任务分配环节")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "jobids",value = "流程任务jobid,多个jobid用[英文逗号]分割"),
            @ApiImplicitParam(name = "dbrid",value = "选择的待办理人id，多个用[英文逗号]分割"),
            @ApiImplicitParam(name = "opinion",value = "办理意见"),
            @ApiImplicitParam(name = "smgflag",value = "是否发送短信"),
    })
    @PostMapping(value = "batchSubmitRwflNode")
    public HttpResult<?> batchSubmitRwflNode(@RequestBody HashMap<String, String> map){
        String jobids = map.get("jobids");
        String dbrid = map.get("dbrid");
        String opinion = map.get("opinion");
        String smgflag = map.get("smgflag");
        if (StringUtils.isBlank(jobids)) {
            return HttpResult.error("流程任务参数不能为空");
        }
        if (StringUtils.isBlank(dbrid)){
            return HttpResult.error("待办理人不能为空");
        }

        StringBuffer errMsg = new StringBuffer();
        List<String> jobIdList = Arrays.asList(jobids.split(",|，"));
        List<SpcySqsxJob> jobList = spcySqsxJobService.listByIds(jobIdList);
        if (CollectionUtils.isEmpty(jobList)){
            return HttpResult.error("流程不存在，请刷新重试");
        }
        for (SpcySqsxJob job : jobList){
            Result result = ylqxFlowService.passJob(job.getFpid(), job.getId(), opinion, YlqxFlowConstant.HJMC_RWFP, dbrid);
            if (!result.isSuccess()){
                SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                errMsg.append(sqsx.getFsxmc()).append("->");
                errMsg.append(result.getMessage());
                errMsg.append("; ").append("\n");
            }
        }

        if (StringUtils.isBlank(errMsg.toString())){
            if (StringUtils.isNotBlank(smgflag)){
                if (smgflag.equals("是") || smgflag.equals("true")) {
                    busService.sendSmsToNodeDbr(dbrid, YlqxFlowConstant.HJMC_RWFP); // 发送短信
                }
            }
            return HttpResult.ok("提交成功");
        }else {
            return HttpResult.error(errMsg.toString());
        }
    }


    /**
     * 废弃退回功能
     */
    public HttpResult<?> returnUpperScSpFlowJobOld(@RequestBody Map<String,String> map){
        String jobid = map.get("jobid");  // 当前流程任务id
        String opinion = map.get("opinion"); // 退回意见
        String shjid = map.get("shjid"); // 退回的环节id

        CurrentUserVo currentUser = GetCurrentUserUtils.getCurrentUser();
        if (currentUser == null){
            return HttpResult.error("登录已失效，请重新登录");
        }
        SpcySqsxJob job = spcySqsxJobService.getById(jobid);
        // 待办-获取上一个环节id
        SpcySqsxJob syhjJob = spcySqsxJobService.getById(shjid);
        if (job == null){
            return HttpResult.error("当前流程任务不存在");
        }
        if (syhjJob == null){
            return HttpResult.error("当前选择退回的环节不存在");
        }
        // 办理状态 - 待办
        if (StringUtils.isNotBlank(job.getFblzt()) && (job.getFblzt().equals(SpcyConstant.BLZT_DB)
                || job.getFblzt().equals(SpcyConstant.BLZT_TH))) {

            SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
            String fscms = sqsx.getFscms(); // 审查模式
            String currentNode = job.getFhjmc(); // 当前环节名称
            boolean isUpdateSqsx = false; // 修改查验、审评相关流程状态
            boolean scmsDel = false; // 审查模式- 查验+审评 是否可以删除流程
            boolean qtDel = false; // 是否删除其他流程状态
            boolean isCurrentZhpd = false; // 当前是否处于综合评定及以后
            String oldshjid = job.getFsyhjid(); // 当前流程上环节

            // 综合审查
            if (currentNode.equals(YlqxFlowConstant.HJMC_ZHSC)){
                // 审查模式- 查验+审评
                if (fscms.equals(SpcyConstant.SQSX_SCMS_SCJCANBJSSC)){
                    // 现场检查
                    if (syhjJob.getFhjmc().equals(YlqxFlowConstant.HJMC_XCJC)){
                        sqsx.setFcywczt("否");
                        spcySqsxBaiscService.updateById(sqsx);

                    }
                    // 技术审评
                    /*if (syhjJob.getFhjmc().equals(YlqxFlowConstant.HJMC_JSSP)){
                        sqsx.setFspwczt("否");
                        spcySqsxBaiscService.updateById(sqsx);
                    }*/
                    if (sqsx.getFcywczt().equals("否") && sqsx.getFspwczt().equals("否")){
                        scmsDel = true;
                    }
                }else {
                    qtDel = true;
                    scmsDel = true;
                }

            }else {
                qtDel = true;
                scmsDel = true;
            }

            // 获取当前环节，不处于查验、也不处于审评环节的状态
            if (currentNode.equals(YlqxFlowConstant.HJMC_RWSL)){
                isCurrentZhpd = true;
            }else if (currentNode.equals(YlqxFlowConstant.HJMC_RWFP)){
                isCurrentZhpd = true;
            }else if (currentNode.equals(YlqxFlowConstant.HJMC_FAZZ)){
                isCurrentZhpd = true;
            }else if (currentNode.equals(YlqxFlowConstant.HJMC_ZHSC)){
                isCurrentZhpd = true;
            }else if (currentNode.equals(YlqxFlowConstant.HJMC_KSFH)){
                isCurrentZhpd = true;
            }else if (currentNode.equals(YlqxFlowConstant.HJMC_YSQR)){
                isCurrentZhpd = true;
            }

            // 当前流程是否是审评相关的,并且要退回到方案制作环节
            boolean isCurrentSp = false;
            /*if (currentNode.contains("审评") && syhjJob.getFhjmc().equals(YlqxFlowConstant.HJMC_FAZZ)){
                isCurrentSp = true;
            }*/

            // 当前流程是否是查验相关的,并且要退回到方案制作环节
            boolean isCurrentCy = false;
            if ((currentNode.contains("查验") || currentNode.contains("检查")) && syhjJob.getFhjmc().equals(YlqxFlowConstant.HJMC_FAZZ)){
                isCurrentCy = true;
            }

            // 如果 当前 流程上环节与 选择 退回的环节 相等 则删除.否则不等，则修改办理状态
            if (qtDel && !oldshjid.equals(shjid)) {
                this.dealDelNodeJobInScms(shjid,isCurrentSp,isCurrentCy,isCurrentZhpd);
            }

            // 退回的环节的一个环节 是否 处于已办, 是已办，才将当前被退环节修改为退回状态
//            List<SpcySqsxJob> sshjList = spcySqsxJobService.list(new LambdaQueryWrapper<SpcySqsxJob>()
//                    .eq(SpcySqsxJob::getFsyhjid, shjid)
//                    .eq(SpcySqsxJob::getFblzt,SpcyConstant.BLZT_YB));
//            if (CollectionUtils.isEmpty(sshjList)) {
            syhjJob.setFthyj(opinion);
            syhjJob.setFfssj(new Date());
            syhjJob.setFblzt(SpcyConstant.BLZT_TH);
            syhjJob.setFfsrid(currentUser.getId());
            syhjJob.setFfsrmc(currentUser.getName());
            boolean flag = spcySqsxJobService.updateById(syhjJob);// 将选中的环节改退回状态
            if (flag){
                // 发送退回短信
                String nextNodeSmsContent = busService.getNextNodeSmsContent(syhjJob, null);
                busService.sendNextNodeSmsContent(syhjJob,nextNodeSmsContent);
            }
//            }

            // 审查模式- 查验+审评
            if (fscms.equals(SpcyConstant.SQSX_SCMS_SCJCANBJSSC)) {
                if (scmsDel) {
                    isUpdateSqsx = true;
                    spcySqsxJobService.removeById(jobid); // 删除当前流程任务待办                    }
                }
            }else {
                isUpdateSqsx = true;
                spcySqsxJobService.removeById(jobid); // 删除当前流程任务待办
            }

            // 修改查验、审评相关流程状态
            if (isUpdateSqsx){
                // 查验方案审核
                if (currentNode.equals(YlqxFlowConstant.HJMC_FASH)) {
                    sqsx.setFcyfazt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }

                // 审评方案审核
                /*if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_SP_FASH)) {
                    sqsx.setFspfazt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }*/

                // 现场检查
                if (currentNode.equals(YlqxFlowConstant.HJMC_XCJC)) {
                    sqsx.setFcywczt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }

                // 技术审评
                /*if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_JSSP)) {
                    sqsx.setFspwczt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }*/
            }

        }

        String logNr = "退回上一环节: 从["+job.getFhjmc()+"]退回到["+syhjJob.getFhjmc()+"];【退回意见】为["+opinion+"]";
        spcyLogService.addLogs(job.getFhjmc(),logNr,job.getFpid(), LogConstant.LOGS_SQSX_JOB,SpcyConstant.LOGS_SYS_TYPE_TH);

        return HttpResult.ok("退回成功");
    }

    /**
     * 废弃功能-现场检查+技术审评模式-获取已办列表-通过当前流程id
     * @param jobid
     * @return
     */
    public HttpResult<?> queryScSpYbJobOld(@RequestParam("jobid")String jobid){

        SpcySqsxJob job = spcySqsxJobService.getById(jobid);
        if (job == null){
            return HttpResult.error("当前流程任务不存在，请刷新重试");
        }

        List<SpcySqsxJob> ybList = new ArrayList<>(); // 已办列表

        // 查询已办列表-除开日常考评流程
        List<SpcySqsxJob> ybJobList = spcySqsxJobService.list(new LambdaQueryWrapper<SpcySqsxJob>()
                .eq(StringUtils.isNotBlank(job.getFpid()), SpcySqsxJob::getFpid, job.getFpid())
                .eq(SpcySqsxJob::getFblzt, SpcyConstant.BLZT_YB)
                .like(SpcySqsxJob::getFlcmc, YpscFlowConstant.LCMC_LIKE_SPCYLC)
                .orderByDesc(SpcySqsxJob::getFblsj));

        // 存在[审评]字眼的流程环节
        if (StringUtils.isNotBlank(job.getFhjmc()) && job.getFhjmc().contains("审评")){
            // 剔除查验相关的流程
            if (CollectionUtils.isNotEmpty(ybJobList)){
                ybList = ybJobList.stream()
                        .filter(f -> StringUtils.isNotBlank(f.getFhjmc()) && (!f.getFhjmc().contains("查验") || !f.getFhjmc().contains("检查")))
                        .collect(Collectors.toList());
            }
        } else if (StringUtils.isNotBlank(job.getFhjmc()) && (job.getFhjmc().contains("查验") || job.getFhjmc().contains("检查"))){
            // 剔除审评相关的流程
            if (CollectionUtils.isNotEmpty(ybJobList)){
                ybList = ybJobList.stream()
                        .filter(f -> StringUtils.isNotBlank(f.getFhjmc()) && !f.getFhjmc().contains("审评"))
                        .collect(Collectors.toList());
            }
        } else {
            // 既不在审评上、也不在查验上
            ybList = ybJobList;
        }

        List<Map<String,String>> ybNodeList = new ArrayList<>(); // 可退回环节list

        // 查询 当前环节不在 任务受理、方案制作的流程
        List<SpcySqsxJob> fazzNodeList = new ArrayList<>(); // 方案制作流程
        if (StringUtils.isNotBlank(job.getFhjmc())
                && !job.getFhjmc().equals(YlqxFlowConstant.HJMC_RWSL)
                && !job.getFhjmc().equals(YlqxFlowConstant.HJMC_FAZZ)) {
            // 查询是否存在方案制作环节, 添加方案制作环节、可退回
            fazzNodeList = spcySqsxJobService.list(new LambdaQueryWrapper<SpcySqsxJob>()
                    .eq(StringUtils.isNotBlank(job.getFpid()), SpcySqsxJob::getFpid, job.getFpid())
                    .eq(SpcySqsxJob::getFhjmc, YlqxFlowConstant.HJMC_FAZZ)
                    .orderByDesc(SpcySqsxJob::getFfssj));
        }

        if (CollectionUtils.isNotEmpty(ybList)){
            for (SpcySqsxJob job1 : ybList){
                // 增加方案制作的环节
                /*if (StringUtils.isNotBlank(job1.getFhjmc()) && job1.getFhjmc().equals(YlqxFlowConstant.HJMC_RWSL)){
                    if (CollectionUtils.isNotEmpty(fazzNodeList)) {
                        Map<String,String> fazzMap = new HashMap<>();
                        fazzMap.put("id",fazzNodeList.get(0).getId());
                        fazzMap.put("fhjmc",fazzNodeList.get(0).getFhjmc());
                        ybNodeList.add(fazzMap);
                    }
                }*/
                Map<String,String> map = new HashMap<>();
                map.put("id",job1.getId());
                map.put("fhjmc",job1.getFhjmc());
                ybNodeList.add(map);
            }
        }

        /**  旧的方法  */
        /*else {
            // 没有已办列表
            boolean isExistNode = true;
            String previousName = "";
            SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
            String fywflcode = "";
            if (sqsx != null){
                fywflcode = sqsx.getFywflcode();
            }else {
                isExistNode = false;
            }

            if (isExistNode) {
                FlowConstant flowConstant = SpcyConstant.getFlowConstant(fywflcode);
                previousName = flowConstant.getPreviousName(job.getFhjmc());
                // 上环节与当前环节相同
                if (StringUtils.isBlank(previousName)) {
                    isExistNode = false;
                    String spPreviousName = flowConstant.getSpPreviousName(job.getFhjmc());
                    if (StringUtils.isBlank(spPreviousName)) {
                        isExistNode = false;
                    }else {
                        previousName = spPreviousName;
                        isExistNode = true;
                    }
                }else {
                    isExistNode = true;
                }
            }

            if (isExistNode) {
                List<SpcySqsxJob> preJobList = spcySqsxJobService.list(new LambdaQueryWrapper<SpcySqsxJob>()
                        .eq(StringUtils.isNotBlank(job.getFpid()), SpcySqsxJob::getFpid, job.getFpid())
                        .eq(SpcySqsxJob::getFhjmc, previousName)
                        .and(q ->
                                q.and(q1 -> q1.eq(SpcySqsxJob::getFblzt, SpcyConstant.BLZT_DB))
                                        .or(q2 -> q2.eq(SpcySqsxJob::getFblzt, SpcyConstant.BLZT_TH))
                        )
                );
                if (CollectionUtils.isNotEmpty(preJobList)){
                    for (SpcySqsxJob job1 : preJobList){
                        Map<String,String> map = new HashMap<>();
                        map.put("id",job1.getId());
                        map.put("fhjmc",job1.getFhjmc());
                        ybNodeList.add(map);
                    }
                }
            }
        }*/

        return HttpResult.ok(ybNodeList);
    }

    /**
     *  递归删除当前流程任务父级的所有流程任务(现场检查+技术审评)
     * @param shjid  上环节id
     * @param isCurrentSp 审评相关状态（true/false）
     * @param isCurrentCy 查验相关状态 (true/false)
     * @param isCurrentZhpd 既不是审评、也不是查验 (true/false)
     * @return
     */
    public String dealDelNodeJobInScms(String shjid,boolean isCurrentSp,boolean isCurrentCy,boolean isCurrentZhpd){
        String id = "";
        // 查询上环节已办流程任务
        List<SpcySqsxJob> shjList = spcySqsxJobService.list(new LambdaQueryWrapper<SpcySqsxJob>()
                .eq(SpcySqsxJob::getFsyhjid, shjid)
                .eq(SpcySqsxJob::getFblzt,SpcyConstant.BLZT_YB));
        if (CollectionUtils.isNotEmpty(shjList)){
            // 循环删除任务
            for (SpcySqsxJob job : shjList) {
                id = job.getId();
                boolean isDel = true;
                // 当前属于审评相关、如果等于 查验相关、不做处理
                if (isCurrentSp && (job.getFhjmc().contains("查验") || job.getFhjmc().contains("检查"))){
                    isDel = false;
                }

                // 查验方案审核
                if (isCurrentCy && job.getFhjmc().equals(YlqxFlowConstant.HJMC_FASH)) {
                    SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                    sqsx.setFcyfazt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }

                // 审评方案审核
                /*if (isCurrentSp && job.getFhjmc().equals(YlqxFlowConstant.HJMC_SP_FASH)) {
                    SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                    sqsx.setFspfazt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }
*/
                // 现场检查
                if (isCurrentCy && job.getFhjmc().equals(YlqxFlowConstant.HJMC_XCJC)) {
                    SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                    sqsx.setFcywczt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }

                // 技术审评
                /*if (isCurrentSp && job.getFhjmc().equals(YlqxFlowConstant.HJMC_JSSP)) {
                    SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                    sqsx.setFspwczt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }*/

                // 当前处于综合评定及以后的环节退回操作
                if (isCurrentZhpd){
                    // 查验方案审核
                    if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_FASH)) {
                        SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                        sqsx.setFcyfazt("否");
                        spcySqsxBaiscService.updateById(sqsx);
                    }

                    // 审评方案审核
                    /*if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_SP_FASH)) {
                        SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                        sqsx.setFspfazt("否");
                        spcySqsxBaiscService.updateById(sqsx);
                    }*/

                    // 现场检查
                    if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_XCJC)) {
                        SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                        sqsx.setFcywczt("否");
                        spcySqsxBaiscService.updateById(sqsx);
                    }

                    // 技术审评
                    /*if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_JSSP)) {
                        SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
                        sqsx.setFspwczt("否");
                        spcySqsxBaiscService.updateById(sqsx);
                    }*/
                }

                // 综合评定
                if (job.getFhjmc().equals(YlqxFlowConstant.HJMC_ZHSC)){
                    SpcySqsxBasic sqsx = spcySqsxBaiscService.getById(job.getFpid());
//                    sqsx.setFspwczt("否");
                    sqsx.setFcywczt("否");
                    spcySqsxBaiscService.updateById(sqsx);
                }

                if (isDel) {
                    spcySqsxJobService.removeById(id);
                }
                return dealDelNodeJobInScms(id,isCurrentSp,isCurrentCy,isCurrentZhpd);  // 递归调用，上环节删除流程任务
            }
        }
        return id;
    }
}
